package com.itheima.springbootinittest10.condition;

import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class ClassCondition implements Condition {
    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
        //导入jedis坐标后,返回true允许返回user对象.
        Boolean flag=true;
        try {
            Class<?> cls = Class.forName("redis.clients.Jedis");//有编译时异常,所以要try;
            // 老师说这个是个文件redis.clients.jedis.Jedis,我怎么知道这个是个文件?
        } catch (ClassNotFoundException e) {
            flag=false;
            e.printStackTrace();
        }

        return flag;
    }
}
